package cn.demo.cm.domain;

import com.mybatisflex.annotation.Column;
import lombok.Data;
import lombok.EqualsAndHashCode;
import com.mybatisflex.annotation.Table;
import com.mybatisflex.annotation.Id;
import com.mybatisflex.core.constant.SqlOperator;
import com.mybatisflex.core.query.SqlOperators;
import cn.demo.common.mybatisFlex.MyInsertListener;
import cn.demo.common.mybatisFlex.MyUpdateListener;
import cn.demo.common.annotation.Excel;
import io.swagger.v3.oas.annotations.media.Schema;
import com.fasterxml.jackson.annotation.JsonIgnore;
import cn.demo.common.core.domain.BaseEntity;

import java.math.BigDecimal;

/**
 * 文章管理对象 cm_content
 *
 * @author xtjun
 * @date 2024-06-04
 */
@EqualsAndHashCode(callSuper = true)
@Data
@Table(value = "cm_content",onInsert = MyInsertListener.class,onUpdate = MyUpdateListener.class)
public class CmContent extends BaseEntity {
    private static final long serialVersionUID = 1L;

    @Id
    @Schema(description = "id")
    private String id;

    @Excel(name = "所属栏目")
    @Schema(description = "所属栏目")
    private String categoryId;

    @Excel(name = "文章标题")
    @Schema(description = "文章标题")
    private String contentTitle;

    @Excel(name = "缩略图")
    @Schema(description = "缩略图")
    private String contentImg;

    @Excel(name = "关键字")
    @Schema(description = "关键字")
    private String contentKeyword;

    @Excel(name = "文章内容")
    @Schema(description = "文章内容")
    private String contentDetails;

    @Excel(name = "文章描述")
    @Schema(description = "文章描述")
    private String contentDescription;

    @Excel(name = "文章点击次数")
    @Schema(description = "文章点击次数")
    private Long contentHit;

    @Excel(name = "虚拟文章点击次数")
    @Schema(description = "虚拟文章点击次数")
    private Long contentHitVirtual;

    @Excel(name = "文章作者")
    @Schema(description = "文章作者")
    private String contentAuthor;

    @Excel(name = "纬度")
    @Schema(description = "纬度")
    private String lat;

    @Excel(name = "经度")
    @Schema(description = "经度")
    private String lng;

    @Excel(name = "排序")
    @Schema(description = "排序")
    private Long sort;

    @Excel(name = "是否推荐", dictType = "sys_yes_no")
    @Schema(description = "是否推荐(字典:sys_yes_no)")
    private Integer isRecommend;

    @Schema(description = "删除标志(字典:sys_del_status)")
    private Integer delFlag;

    @Excel(name = "状态", dictType = "sys_data_status")
    @Schema(description = "状态(字典:sys_data_status)")
    private Integer status;

    @Excel(name = "部门id")
    @Schema(description = "部门id")
    private String deptId;

    @Column(ignore = true)
    @Schema(description = "是否关注")
    private Boolean isFocus;

    @Column(ignore = true)
    @Schema(description = "距离")
    private BigDecimal distance;


    // 自定义字段的 SQL 操作符
    @JsonIgnore
    public static final SqlOperators operators = new SqlOperators() {{
        set(CmContent::getCategoryId, SqlOperator.EQUALS);
        set(CmContent::getContentTitle, SqlOperator.LIKE);
        set(CmContent::getContentKeyword, SqlOperator.EQUALS);
        set(CmContent::getContentHit, SqlOperator.EQUALS);
        set(CmContent::getContentHitVirtual, SqlOperator.EQUALS);
        set(CmContent::getContentAuthor, SqlOperator.EQUALS);
        set(CmContent::getLat, SqlOperator.EQUALS);
        set(CmContent::getLng, SqlOperator.EQUALS);
        set(CmContent::getSort, SqlOperator.EQUALS);
        set(CmContent::getIsRecommend, SqlOperator.EQUALS);
        set(CmContent::getStatus, SqlOperator.EQUALS);
        set(CmContent::getDeptId, SqlOperator.EQUALS);
    }};
}
